import axios from 'axios'

const state ={
  onFireMovieList:[],
  soonFireMovieList:[],
  classicMovieList:[]
}

const actions ={
  getOnFireMovies({commit}){
    /*
    * */
    axios.get('/api/filmlist/scorefilm')
      .then((resp)=>{
        //console.log(resp);
        const onFireMovieList = resp.data
        //console.log(movieList);
        commit('storeOnMovies',onFireMovieList)

      },(error)=>{
        console.error(error);
      })
  },
  getSoonFireMovies({commit}){
    axios.get('/api/filmlist/hotfilm')
      .then((resp)=>{
        //console.log(resp);
        const soonFireMovieList = resp.data
        //console.log(soonFireMovieList);
        commit('storeSoonMovies',soonFireMovieList)

      },(error)=>{
        console.error(error);
      })
  },
  getClassicMovies({commit}){
    /*
    * 经典电影
    * */
    axios.get('/api/film/onFireTypeFilm')
      .then((resp)=>{
        //console.log(resp);
        const classicMovieList = resp.data
        //console.log(soonFireMovieList);
        commit('storeClassicMovies',classicMovieList)

      },(error)=>{
        console.error(error);
      })
  }
}

const mutations ={
  storeOnMovies(state,onFireMovieList){
    state.onFireMovieList = onFireMovieList
    //console.log(state.movieList);
  },
  storeSoonMovies(state,soonFireMovieList){
    state.soonFireMovieList = soonFireMovieList
    //console.log(state.movieList);
  },
  storeClassicMovies(state,classicMovieList){
    state.classicMovieList = classicMovieList
    //console.log(state.movieList);
  }
}

const getters ={
  onFireMovieList(state){
    return state.onFireMovieList
  },
  soonFireMovieList(state){
    return state.soonFireMovieList
  },
  classicMovieList(state){
    return state.classicMovieList
  }
}

export default {
  state,
  actions,
  mutations,
  getters
}
